home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / bytesc88.arc / GETARG.C < prev    next >
Text File  |  1987-10-04  |  768b  |  30 lines

  1. #define NOCCARGC  /* no argument count passing */
  2. #include stdio.h
  3. /*
  4. ** Get command line argument. 
  5. ** Entry: n    = Number of the argument.
  6. **        s    = Destination string pointer.
  7. **        size = Size of destination string.
  8. **        argc = Argument count from main().
  9. **        argv = Argument vector(s) from main().
  10. ** Returns number of characters moved on success,
  11. ** else EOF.
  12. */
  13. getarg(n,s,size,argc,argv)
  14.   int n; char *s; int size, argc, argv[]; {
  15.   char *str;
  16.   int i;
  17.   if(n < 0 | n >= argc) {
  18.     *s = NULL;
  19.     return EOF;
  20.     }
  21.   i = 0;
  22.   str=argv[n];
  23.   while(i<size) {
  24.     if((s[i]=str[i])==NULL) break;
  25.     ++i;
  26.     }
  27.   s[i]=NULL;
  28.   return i;
  29.   }
  30.